package com.bdrm.mapper;

import com.bdrm.annotation.AutoFill;
import com.bdrm.dto.EmployeePageQueryDTO;
import com.bdrm.entity.Employee;
import com.bdrm.enumeration.OperationType;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface EmployeeMapper {
    @Select("select * from employee where username = #{username}")
    Employee getByUsername(String username);

    @Insert("insert into employee(name,username,password,phone,sex,id_number,status,create_time,update_time,create_user,update_user)" +
            "values"+
            "(#{name},#{username},#{password},#{phone},#{sex},#{idNumber},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")

    @AutoFill(OperationType.INSERT)
    void insert(Employee employee);

    //  分页查询
    Page<Employee> pageQuery(EmployeePageQueryDTO employeePageQueryDTO);

    @AutoFill(OperationType.UPDATE)
    void update(Employee employee);

    @Select("select * from employee where id = #{id}")
    Employee getByIdUse(Long id);

    @Delete("delete from employee where id = #{id}")
    void deleteById(Long id);
}
